package inabit.inabitcompiler.productions.variable.types;

import inabit.compiler.parser.grammar.NonTerminal;
import inabit.compiler.parser.grammar.Production;
import inabit.compiler.parser.grammar.Symbol;
import inabit.compiler.parser.grammar.Terminal;
import inabit.inabitcompiler.lexical.InabitTokenClass;
import inabit.inabitcompiler.parser.InabitSemanticAction;

/**T -> continuous(N, N)*/
/**@author Rafael Rocha*/
public class T_Rule extends Production{
	private NonTerminal N_min;
	private NonTerminal N_max;
	
	public T_Rule() {
		super("T");
	}

	@Override
	protected Symbol[] production(final NonTerminal nonTerminal) {
		N_min = new NonTerminal("N");
		N_max = new NonTerminal("N");
		Symbol[] symbols = {
				new Terminal(InabitTokenClass.CONTINUOUS),
				new Terminal(InabitTokenClass.OPEN_PARENTHESIS),
				N_min,
				new Terminal(InabitTokenClass.COMMA),
				N_max,
				new Terminal(InabitTokenClass.CLOSE_PARENTHESIS),
				new InabitSemanticAction(nonTerminal) {
					
					@Override
					public void execute() throws Exception {
						nonTerminal.code = "continuous:" + N_min.code + "," + N_max.code;
					}
				}
		};
		return symbols;
	}
}
